﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.CodeDom.Compiler;

namespace RobotBattle2.Scripting {
	public sealed class IfStatement : Statement {
		public Expression Condition { get; set; }

		public StatementCollection TrueStatements { get { return m_TrueStatements; } }
		private StatementCollection m_TrueStatements = new StatementCollection();

		public StatementCollection FalseStatements { get { return m_FalseStatements; } }
		private StatementCollection m_FalseStatements = new StatementCollection();

		public override void Dump(IndentedTextWriter writer) {
			writer.Write("if (");
			Condition.Dump(writer);
			writer.WriteLine(")");
			TrueStatements.Dump(writer);
			if (FalseStatements.Count > 0) {
				writer.WriteLine("else");
				FalseStatements.Dump(writer);
			}
			writer.WriteLine("endif");
		}

		public override StatementType Type { get { return StatementType.If; } }
	}
}
